﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ServerMonitor.Helper.Currency;
using ServerMonitor.Helper;

namespace ServerMonitor.Tool.MainInterface
{
    public partial class SiteControl : UserControl
    {
        public SiteControl()
        {
            InitializeComponent();
            InitView();
        }

        private void InitView()
        {
            listBox1.Items.AddRange(Tool.LocalView.AddListItems());
            if (FileHelper.FileExits(StaticValue.BinPath + "server"))
                timer1.Enabled = true;
            else
                timer1.Enabled = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SiteScanner.Start(listBox1);
        }
     static   int TimeCount = 0;
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (TimeCount++ < 10)
                label1.Text = string.Format("距离自动运行还有{0}秒", 10 - TimeCount);
            else
            {
                timer1.Enabled = false;
                SiteScanner.Start(listBox1);
             
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            timer1.Enabled = false;
        }
    }
}
